package org.zxyj.core.entity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import org.zxyj.core.constants.SysParamsDict;
import org.zxyj.core.utils.MessageUtil;

/**
 * @author zhaoyong
 * @version 2015年10月20日
 */
public class Result<T> implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3905977480041177474L;

	/**
	 * 结果码
	 */
	private String resultCode;

	/**
	 * 消息
	 */
	private String message;

	/**
     * 是否成功
     */
    private boolean success;
    
	/**
	 * 数据
	 */
	private T data;

	public String getResultCode() {
		return resultCode;
	}

	public void setResultCode(String resultCode) {
		this.resultCode = resultCode;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public Result() {
		this.setResultCode(SysParamsDict.STATUS_CODE.SUCCESS.getValue());
        this.setSuccess(true);
        this.setMessage(MessageUtil.getMessage("sys.success"));
    }
	
	/**
     * 自定义返回的结果
     *
     * @param data
     * @param message
     * @param success
     */
    public Result(T data,String message, boolean success) {
        this.data = data;
        this.setMessage(message);
        this.setSuccess(success);
    }

    /**
     * 成功返回数据和消息
     *
     * @param  hashMap
     * @param message
     */
    public Result(T data, String message) {
        this.data = data;
        this.setMessage(message);
        this.setSuccess(true);
    }

    /**
     * 成功返回数据
     *
     * @param data
     */
    public Result(T data) {
        this.data = data;
        this.setResultCode(SysParamsDict.STATUS_CODE.SUCCESS.getValue());
        this.setSuccess(true);
        this.setMessage(MessageUtil.getMessage("sys.success"));
    }

	public void setData(Map<String, Object> data) {
		this.data = (T) data;
	}
}